<?php $this->registerResourcePackage('bootstrapSelect')?>
<?php if (false === array_key_exists('multiple', $params)) { $params['multiple'] = false; } ?>


<div class="form-group">
	<div class="col-sm-5">
		<div class="select-wrapper" data-trigger="manual" data-toggle="popover" 
			data-placement="auto left" data-errors='<?= json_encode($errors)?>'>
				<select class="selectpicker" data-width="auto"
				<?= $params['multiple'] ? 'multiple' : ''?>
				title="<?=$params['label']?>"
				<?= $this->prepareAttr($params['htmlOptions']) ?>
				name="<?=$name . ($params['multiple']?'[]':'')?>">
				<?php foreach($params['options'] as $optionName => $optionValue)
					if (!($params['multiple'] && null === $optionValue)) { ?>
					<option <?php if ((string)$value === (string)$optionName || (is_array($value) && in_array($optionName, $value))) {
						echo 'selected';} ?>
					value="<?= $this->txt2attr($optionName) ?>"><?= $this->txt2html($optionValue); ?></option>
				<?php } ?>
			</select>
		</div>
	</div>
</div>
